<template>
  <div class="postInfo">
    <Header>
      <template #left>
        <span @click="$router.go(-1)">返回</span>
      </template>
    </Header>
    <div class="card">
    <div v-html="content" class="content"></div>
    </div>
    <!-- <componentsCeil>
      <template #perComment>
            <van-field style="height:80px" v-model.trim="value"  placeholder="请输入评论内容..." /> 
        </template>
        <template #submit>
            <van-button class="submit" style="width:100%" type="info" @click="subComments">发布评论</van-button>
        </template>
        <template #allComments>
            <van-list v-model="loading"
                  :finished="finished"
                  finished-text="没有更多了"
                  @load="onLoad"
                  :immediate-check="false">
                <van-cell v-for="(item,index) in list" 
                          :key="index" 
                          :title="item.content"
                          :value="item.add_time"
                          :label="item.user_name" />
            </van-list>
        </template>
    </componentsCeil> -->
    <commentList>

    </commentList>
    
  </div>
</template>

<script>
import Header from "@/components/Header";
import commentList from "@/views/commentList";
// import componentsCeil from "@/components/componentsCeil";
// import { postComments } from "../apis/comments";
// import { getComments } from "../apis/comments";
import { getnew } from "@/apis/News";
export default {
  components: {
    Header,
    commentList
    // componentsCeil
  },
  data() {
    return {
      content: "",
      // list: [],
      // page:1,
      // loading:false,
      // finished:false,
      // value:'',
    };
  },
  mounted() {
    getnew(this.$route.params.id)
      .then((res) => {
        // console.log(res);
        this.content = res.data.message[0].content;
        // console.log(this.content);
      })
      .catch((err) => {
        // console.log(err);
      });
  },
  // methods: {
    
  //   onLoad(){
  //       this.page++
  //   },
  //   subComments(){
  //       if (this.value == '') {
  //           this.$toast.fail('评论不能为空喔')
  //       }else{
  //           postComments(this.$route.params.id,this.value)
  //           .then(res => {
  //               //console.log(res);
  //           })
  //           getComments(this.imgId,{pageindex:this.page})
  //           .then(res => {
  //               //console.log(res);
  //               this.list = res.data.message
  //               //console.log(this.list);
  //               for (let i = 0; i < this.list.length; i++) {
  //                   this.list[i].user_name
  //               }
  //               this.loading = false;
  //               if (res.data.message < 10) {
  //                   this.finished = true
  //               }
  //           })
  //           this.$toast.success('评论发表成功！')
  //           this.value = ''
  //       }
    // },     
  // }
};
</script>
<style lang="less" scoped>
.postInfo {
  
  .card {
    margin: 0 auto;
    width: 90%;
    box-shadow: #ccc 0px 0px 1px 0.5px;
    padding: 20px;
    .content{
      line-height: 1.5em;
      text-indent: 2em;
    }
  }
}
</style>